home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 February: Tool Chest / Dev.CD Feb 99 TC.toast / What's New? / Development Kits / Mac OS USB v1.1f3 DDK / USB.h < prev   
Encoding:
C/C++ Source or Header  |  1999-01-07  |  32.2 KB  |  1,226 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        USB.h
  3.  
  4.      Contains:    Public API for USB Services Library (and associated components)
  5.  
  6.      Version:    
  7.  
  8. */
  9. #ifndef __USB__
  10. #define __USB__
  11.  
  12. #ifndef __MACTYPES__
  13. #include <MacTypes.h>
  14. #endif
  15. #ifndef __NAMEREGISTRY__
  16. #include <NameRegistry.h>
  17. #endif
  18. #ifndef __CODEFRAGMENTS__
  19. #include <CodeFragments.h>
  20. #endif
  21. #ifndef __DEVICES__
  22. #include <Devices.h>
  23. #endif
  24.  
  25.  
  26.  
  27. #if PRAGMA_ONCE
  28. #pragma once
  29. #endif
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34.  
  35. #if PRAGMA_IMPORT
  36. #pragma import on
  37. #endif
  38.  
  39. #if PRAGMA_STRUCT_ALIGN
  40.     #pragma options align=mac68k
  41. #elif PRAGMA_STRUCT_PACKPUSH
  42.     #pragma pack(push, 2)
  43. #elif PRAGMA_STRUCT_PACK
  44.     #pragma pack(2)
  45. #endif
  46.  
  47. /* ************* Constants ************* */
  48.  
  49. enum {
  50.     kUSBNoErr                    = 0,
  51.     kUSBNoTran                    = 0,
  52.     kUSBNoDelay                    = 0,
  53.     kUSBPending                    = 1,                            /* */
  54.                                                                 /* USB assigned error numbers in range -6900 .. -6999 */
  55.     kUSBBaseError                = -7000,                        /* */
  56.                                                                 /* USB Services Errors */
  57.     kUSBInternalErr                = -6999,                        /* Internal error */
  58.     kUSBUnknownDeviceErr        = -6998,                        /*  device ref not recognised */
  59.     kUSBUnknownPipeErr            = -6997,                        /*  Pipe ref not recognised */
  60.     kUSBTooManyPipesErr            = -6996,                        /*  Too many pipes */
  61.     kUSBIncorrectTypeErr        = -6995,                        /*  Incorrect type */
  62.     kUSBRqErr                    = -6994,                        /*  Request error */
  63.     kUSBUnknownRequestErr        = -6993,                        /*  Unknown request */
  64.     kUSBTooManyTransactionsErr    = -6992,                        /*  Too many transactions */
  65.     kUSBAlreadyOpenErr            = -6991,                        /*  Already open */
  66.     kUSBNoDeviceErr                = -6990,                        /*  No device */
  67.     kUSBDeviceErr                = -6989,                        /*  Device error */
  68.     kUSBOutOfMemoryErr            = -6988,                        /*  Out of memory */
  69.     kUSBNotFound                = -6987,                        /*  Not found */
  70.     kUSBPBVersionError            = -6986,                        /*  Wrong pbVersion */
  71.     kUSBPBLengthError            = -6985,                        /*  pbLength too small */
  72.     kUSBCompletionError            = -6984,                        /*  no completion routine specified */
  73.     kUSBFlagsError                = -6983,                        /*  Unused flags not zeroed */
  74.     kUSBAbortedError            = -6982,                        /*  Pipe aborted */
  75.     kUSBNoBandwidthError        = -6981,                        /*  Not enough bandwidth available */
  76.     kUSBPipeIdleError            = -6980,                        /*  Pipe is Idle, it will not accept transactions */
  77.     kUSBPipeStalledError        = -6979,                        /*  Pipe has stalled, error needs to be cleared */
  78.     kUSBUnknownInterfaceErr        = -6978,                        /*  Interface ref not recognised */
  79.     kUSBDeviceBusy                = -6977,                        /*  Device is already being configured */
  80.     kUSBDevicePowerProblem        = -6976,                        /*  Device has a power problem */
  81.                                                                 /* */
  82.                                                                 /* USB Manager Errors */
  83.     kUSBBadDispatchTable        = -6950,                        /* Improper driver dispatch table */
  84.     kUSBUnknownNotification        = -6949,                        /* Notification type not defined */
  85.     kUSBQueueFull                = -6948,                        /* Internal queue maxxed */
  86.                                                                 /* */
  87.                                                                 /* Hardware Errors */
  88.                                                                 /* Note pipe stalls are communication */
  89.                                                                 /* errors. The affected pipe can not */
  90.                                                                 /* be used until USBClearPipeStallByReference  */
  91.                                                                 /* is used */
  92.                                                                 /* kUSBEndpointStallErr is returned in */
  93.                                                                 /* response to a stall handshake */
  94.                                                                 /* from a device. The device has to be */
  95.                                                                 /* cleared before a USBClearPipeStallByReference */
  96.                                                                 /* can be used */
  97.     kUSBLinkErr                    = -6916,
  98.     kUSBCRCErr                    = -6915,                        /*  Pipe stall, bad CRC */
  99.     kUSBBitstufErr                = -6914,                        /*  Pipe stall, bitstuffing */
  100.     kUSBDataToggleErr            = -6913,                        /*  Pipe stall, Bad data toggle */
  101.     kUSBEndpointStallErr        = -6912,                        /*  Device didn't understand */
  102.     kUSBNotRespondingErr        = -6911,                        /*  Pipe stall, No device, device hung */
  103.     kUSBPIDCheckErr                = -6910,                        /*  Pipe stall, PID CRC error */
  104.     kUSBWrongPIDErr                = -6909,                        /*  Pipe stall, Bad or wrong PID */
  105.     kUSBOverRunErr                = -6908,                        /*  Packet too large or more data than buffer */
  106.     kUSBUnderRunErr                = -6907,                        /*  Less data than buffer */
  107.     kUSBRes1Err                    = -6906,
  108.     kUSBRes2Err                    = -6905,
  109.     kUSBBufOvrRunErr            = -6904,                        /*  Host hardware failure on data in, PCI busy? */
  110.     kUSBBufUnderRunErr            = -6903,                        /*  Host hardware failure on data out, PCI busy? */
  111.     kUSBNotSent1Err                = -6902,                        /*  Transaction not sent */
  112.     kUSBNotSent2Err                = -6901                            /*  Transaction not sent */
  113. };
  114.  
  115.  
  116. enum {
  117.                                                                 /* Flags */
  118.     kUSBTaskTimeFlag            = 1,
  119.     kUSBHubPower                = 2,
  120.     kUSBPowerReset                = 4,
  121.     kUSBHubReaddress            = 8,
  122.     kUSBAddressRequest            = 16
  123. };
  124.  
  125.  
  126. enum {
  127.                                                                 /* Hub messages */
  128.     kUSBHubPortResetRequest        = 1
  129. };
  130.  
  131. /* ************* types ************* */
  132.  
  133. typedef SInt32                             USBReference;
  134. typedef USBReference                     USBDeviceRef;
  135. typedef USBReference                     USBInterfaceRef;
  136. typedef USBReference                     USBPipeRef;
  137. typedef USBReference                     USBBusRef;
  138. typedef UInt32                             USBPipeState;
  139. typedef UInt32                             USBCount;
  140. typedef UInt32                             USBFlags;
  141. typedef UInt8                             USBRequest;
  142. typedef UInt8                             USBDirection;
  143. typedef UInt8                             USBRqRecipient;
  144. typedef UInt8                             USBRqType;
  145. typedef UInt16                             USBRqIndex;
  146. typedef UInt16                             USBRqValue;
  147.  
  148.  
  149.  
  150. struct usbControlBits {
  151.     UInt8                             BMRequestType;
  152.     UInt8                             BRequest;
  153.     USBRqValue                         WValue;
  154.     USBRqIndex                         WIndex;
  155.     UInt16                             reserved4;
  156. };
  157. typedef struct usbControlBits            usbControlBits;
  158.  
  159. struct USBIsocFrame {
  160.     OSStatus                         frStatus;
  161.     UInt16                             frReqCount;
  162.     UInt16                             frActCount;
  163. };
  164. typedef struct USBIsocFrame                USBIsocFrame;
  165.  
  166. struct usbIsocBits {
  167.     USBIsocFrame *                    FrameList;
  168.     UInt32                             NumFrames;
  169. };
  170. typedef struct usbIsocBits                usbIsocBits;
  171.  
  172. struct usbHubBits {
  173.     UInt32                             Request;
  174.     UInt32                             Spare;
  175. };
  176. typedef struct usbHubBits                usbHubBits;
  177. typedef struct USBPB                     USBPB;
  178. typedef CALLBACK_API_C( void , USBCompletion )(USBPB *pb);
  179.  
  180. struct USBPB {
  181.  
  182.     void *                            qlink;
  183.     UInt16                             qType;
  184.     UInt16                             pbLength;
  185.     UInt16                             pbVersion;
  186.     UInt16                             reserved1;
  187.     UInt32                             reserved2;
  188.  
  189.     OSStatus                         usbStatus;
  190.     USBCompletion                     usbCompletion;
  191.     UInt32                             usbRefcon;
  192.  
  193.     USBReference                     usbReference;
  194.  
  195.     void *                            usbBuffer;
  196.     USBCount                         usbReqCount;
  197.     USBCount                         usbActCount;
  198.  
  199.     USBFlags                         usbFlags;
  200.  
  201.     union{
  202.  
  203.     usbControlBits                     cntl;
  204.  
  205.  
  206.     usbIsocBits                        isoc;
  207.  
  208.     usbHubBits                        hub;
  209.  
  210.     }usb;
  211.  
  212.     UInt32                             usbFrame;
  213.  
  214.     UInt8                             usbClassType;
  215.     UInt8                             usbSubclass;
  216.     UInt8                             usbProtocol;
  217.     UInt8                             usbOther;
  218.  
  219.     UInt32                             reserved6;
  220.     UInt16                             reserved7;
  221.     UInt16                             reserved8;
  222.  
  223. };
  224.  
  225. #if !defined(OLDUSBNAMES)
  226. #define OLDUSBNAMES 0
  227. #endif
  228.  
  229. #if OLDUSBNAMES
  230. #define usbBMRequestType  usb.cntl.BMRequestType
  231. #define usbBRequest       usb.cntl.BRequest
  232. #define usbWValue         usb.cntl.WValue
  233. #define usbWIndex         usb.cntl.WIndex
  234. #endif
  235.  
  236. struct uslReq {
  237.     USBDirection                     usbDirection;
  238.     USBRqType                         usbType;
  239.     USBRqRecipient                     usbRecipient;
  240.     USBRequest                         usbRequest;
  241. };
  242. typedef struct uslReq                    uslReq;
  243.  
  244.  
  245. enum {
  246.                                                                 /* BT 19Aug98, bump up to v1.10 for Isoc*/
  247.     kUSBCurrentPBVersion        = 0x0100,                        /* v1.00*/
  248.     kUSBIsocPBVersion            = 0x0109,                        /* v1.10*/
  249.     kUSBCurrentHubPB            = kUSBIsocPBVersion
  250. };
  251.  
  252.  
  253.  
  254.  
  255. #define kUSBNoCallBack ((void *)-1L)
  256.  
  257.  
  258. typedef UInt8                             bcdUSB;
  259.  
  260. enum {
  261.     kUSBControl                    = 0,
  262.     kUSBIsoc                    = 1,
  263.     kUSBBulk                    = 2,
  264.     kUSBInterrupt                = 3,
  265.     kUSBAnyType                    = 0xFF
  266. };
  267.  
  268. /* endpoint type */
  269.  
  270. enum {
  271.     kUSBOut                        = 0,
  272.     kUSBIn                        = 1,
  273.     kUSBNone                    = 2,
  274.     kUSBAnyDirn                    = 3
  275. };
  276.  
  277. /*USBDirection*/
  278.  
  279. enum {
  280.     kUSBStandard                = 0,
  281.     kUSBClass                    = 1,
  282.     kUSBVendor                    = 2
  283. };
  284.  
  285. /*USBRqType*/
  286.  
  287. enum {
  288.     kUSBDevice                    = 0,
  289.     kUSBInterface                = 1,
  290.     kUSBEndpoint                = 2,
  291.     kUSBOther                    = 3
  292. };
  293.  
  294. /*USBRqRecipient*/
  295.  
  296. enum {
  297.     kUSBRqGetStatus                = 0,
  298.     kUSBRqClearFeature            = 1,
  299.     kUSBRqReserved1                = 2,
  300.     kUSBRqSetFeature            = 3,
  301.     kUSBRqReserved2                = 4,
  302.     kUSBRqSetAddress            = 5,
  303.     kUSBRqGetDescriptor            = 6,
  304.     kUSBRqSetDescriptor            = 7,
  305.     kUSBRqGetConfig                = 8,
  306.     kUSBRqSetConfig                = 9,
  307.     kUSBRqGetInterface            = 10,
  308.     kUSBRqSetInterface            = 11,
  309.     kUSBRqSyncFrame                = 12
  310. };
  311.  
  312. /*USBRequest*/
  313.  
  314.  
  315. enum {
  316.     kUSBDeviceDesc                = 1,
  317.     kUSBConfDesc                = 2,
  318.     kUSBStringDesc                = 3,
  319.     kUSBInterfaceDesc            = 4,
  320.     kUSBEndpointDesc            = 5,
  321.     kUSBHIDDesc                    = 0x21,
  322.     kUSBReportDesc                = 0x22,
  323.     kUSBPhysicalDesc            = 0x23,
  324.     kUSBHUBDesc                    = 0x29
  325. };
  326.  
  327. /* descriptorType */
  328.  
  329.  
  330. enum {
  331.     kUSBFeatureDeviceRemoteWakeup = 1,
  332.     kUSBFeatureEndpointStall    = 0
  333. };
  334.  
  335. /* Feature selectors */
  336.  
  337. enum {
  338.     kUSBActive                    = 0,                            /* Pipe can accept new transactions*/
  339.     kUSBIdle                    = 1,                            /* Pipe will not accept new transactions*/
  340.     kUSBStalled                    = 2                                /* An error occured on the pipe*/
  341. };
  342.  
  343.  
  344. enum {
  345.     kUSB100mAAvailable            = 50,
  346.     kUSB500mAAvailable            = 250,
  347.     kUSB100mA                    = 50,
  348.     kUSBAtrBusPowered            = 0x80,
  349.     kUSBAtrSelfPowered            = 0x40,
  350.     kUSBAtrRemoteWakeup            = 0x20
  351. };
  352.  
  353.  
  354. enum {
  355.     kUSBRel10                    = 0x0100
  356. };
  357.  
  358. #define USB_CONSTANT16(x)    ((((x) >> 8) & 0x0ff) | ((x & 0xff) << 8))
  359.  
  360. enum {
  361.     kUSBDeviceDescriptorLength    = 0x12,
  362.     kUSBInterfaceDescriptorLength = 0x09
  363. };
  364.  
  365.  
  366. struct USBDeviceDescriptor {
  367.     UInt8                             length;
  368.     UInt8                             descType;
  369.     UInt16                             usbRel;
  370.     UInt8                             deviceClass;
  371.     UInt8                             deviceSubClass;
  372.     UInt8                             protocol;
  373.     UInt8                             maxPacketSize;
  374.     UInt16                             vendor;
  375.     UInt16                             product;
  376.     UInt16                             devRel;
  377.     UInt8                             manuIdx;
  378.     UInt8                             prodIdx;
  379.     UInt8                             serialIdx;
  380.     UInt8                             numConf;
  381.     UInt16                             descEnd;                    /* was "end", but this is reserved in some languages*/
  382. };
  383. typedef struct USBDeviceDescriptor        USBDeviceDescriptor;
  384. #ifndef OLDCLASSNAMES
  385. #ifndef __cplusplus
  386. #define class deviceClass
  387. #define subClass deviceSubClass
  388. #endif
  389. #endif
  390. typedef USBDeviceDescriptor *            USBDeviceDescriptorPtr;
  391.  
  392. struct USBDescriptorHeader {
  393.     UInt8                             length;
  394.     UInt8                             descriptorType;
  395. };
  396. typedef struct USBDescriptorHeader        USBDescriptorHeader;
  397. typedef USBDescriptorHeader *            USBDescriptorHeaderPtr;
  398.  
  399. struct USBConfigurationDescriptor {
  400.     UInt8                             length;
  401.     UInt8                             descriptorType;
  402.     UInt16                             totalLength;
  403.     UInt8                             numInterfaces;
  404.     UInt8                             configValue;
  405.     UInt8                             configStrIndex;
  406.     UInt8                             attributes;
  407.     UInt8                             maxPower;
  408. };
  409. typedef struct USBConfigurationDescriptor USBConfigurationDescriptor;
  410. typedef USBConfigurationDescriptor *    USBConfigurationDescriptorPtr;
  411.  
  412. struct USBInterfaceDescriptor {
  413.     UInt8                             length;
  414.     UInt8                             descriptorType;
  415.     UInt8                             interfaceNumber;
  416.     UInt8                             alternateSetting;
  417.     UInt8                             numEndpoints;
  418.     UInt8                             interfaceClass;
  419.     UInt8                             interfaceSubClass;
  420.     UInt8                             interfaceProtocol;
  421.     UInt8                             interfaceStrIndex;
  422. };
  423. typedef struct USBInterfaceDescriptor    USBInterfaceDescriptor;
  424. typedef USBInterfaceDescriptor *        USBInterfaceDescriptorPtr;
  425.  
  426. struct USBEndPointDescriptor {
  427.     UInt8                             length;
  428.     UInt8                             descriptorType;
  429.     UInt8                             endpointAddress;
  430.     UInt8                             attributes;
  431.     UInt16                             maxPacketSize;
  432.     UInt8                             interval;
  433. };
  434. typedef struct USBEndPointDescriptor    USBEndPointDescriptor;
  435. typedef USBEndPointDescriptor *            USBEndPointDescriptorPtr;
  436.  
  437. struct USBHIDDescriptor {
  438.     UInt8                             descLen;
  439.     UInt8                             descType;
  440.     UInt16                             descVersNum;
  441.     UInt8                             hidCountryCode;
  442.     UInt8                             hidNumDescriptors;
  443.     UInt8                             hidDescriptorType;
  444.     UInt8                             hidDescriptorLengthLo;        /* can't make this a single 16bit value or the compiler will add a filler byte*/
  445.     UInt8                             hidDescriptorLengthHi;
  446. };
  447. typedef struct USBHIDDescriptor            USBHIDDescriptor;
  448. typedef USBHIDDescriptor *                USBHIDDescriptorPtr;
  449.  
  450. struct USBHIDReportDesc {
  451.     UInt8                             hidDescriptorType;
  452.     UInt8                             hidDescriptorLengthLo;        /* can't make this a single 16bit value or the compiler will add a filler byte*/
  453.     UInt8                             hidDescriptorLengthHi;
  454. };
  455. typedef struct USBHIDReportDesc            USBHIDReportDesc;
  456. typedef USBHIDReportDesc *                USBHIDReportDescPtr;
  457.  
  458. struct USBHubPortStatus {
  459.     UInt16                             portFlags;                    /* Port status flags */
  460.     UInt16                             portChangeFlags;            /* Port changed flags */
  461. };
  462. typedef struct USBHubPortStatus            USBHubPortStatus;
  463. typedef USBHubPortStatus *                USBHubPortStatusPtr;
  464. /* ********* ProtoTypes *************** */
  465. /* For dealing with endianisms */
  466. EXTERN_API_C( UInt16 )
  467. HostToUSBWord                    (UInt16                 value);
  468.  
  469. EXTERN_API_C( UInt16 )
  470. USBToHostWord                    (UInt16                 value);
  471.  
  472. EXTERN_API_C( UInt32 )
  473. HostToUSBLong                    (UInt32                 value);
  474.  
  475. EXTERN_API_C( UInt32 )
  476. USBToHostLong                    (UInt32                 value);
  477.  
  478. /* Main prototypes */
  479. /* Transfer commands */
  480. EXTERN_API_C( OSStatus )
  481. USBDeviceRequest                (USBPB *                pb);
  482.  
  483. EXTERN_API_C( OSStatus )
  484. USBOpenPipe                        (USBPB *                pb);
  485.  
  486. EXTERN_API_C( OSStatus )
  487. USBClosePipe                    (USBPB *                pb);
  488.  
  489. EXTERN_API_C( OSStatus )
  490. USBBulkWrite                    (USBPB *                pb);
  491.  
  492. EXTERN_API_C( OSStatus )
  493. USBBulkRead                        (USBPB *                pb);
  494.  
  495. EXTERN_API_C( OSStatus )
  496. USBIntRead                        (USBPB *                pb);
  497.  
  498. EXTERN_API_C( OSStatus )
  499. USBIsocRead                        (USBPB *                pb);
  500.  
  501. EXTERN_API_C( OSStatus )
  502. USBIsocWrite                    (USBPB *                pb);
  503.  
  504. /* Pipe state control */
  505. EXTERN_API_C( OSStatus )
  506. USBClearPipeStallByReference    (USBPipeRef             ref);
  507.  
  508. EXTERN_API_C( OSStatus )
  509. USBAbortPipeByReference            (USBReference             ref);
  510.  
  511. EXTERN_API_C( OSStatus )
  512. USBResetPipeByReference            (USBReference             ref);
  513.  
  514. EXTERN_API_C( OSStatus )
  515. USBSetPipeIdleByReference        (USBPipeRef             ref);
  516.  
  517. EXTERN_API_C( OSStatus )
  518. USBSetPipeActiveByReference        (USBPipeRef             ref);
  519.  
  520. EXTERN_API_C( OSStatus )
  521. USBClosePipeByReference            (USBPipeRef             ref);
  522.  
  523. EXTERN_API_C( OSStatus )
  524. USBGetPipeStatusByReference        (USBReference             ref,
  525.                                  USBPipeState *            state);
  526.  
  527.  
  528. /* Configuration services */
  529. EXTERN_API_C( OSStatus )
  530. USBFindNextInterface            (USBPB *                pb);
  531.  
  532. EXTERN_API_C( OSStatus )
  533. USBOpenDevice                    (USBPB *                pb);
  534.  
  535. EXTERN_API_C( OSStatus )
  536. USBSetConfiguration                (USBPB *                pb);
  537.  
  538. EXTERN_API_C( OSStatus )
  539. USBNewInterfaceRef                (USBPB *                pb);
  540.  
  541. EXTERN_API_C( OSStatus )
  542. USBDisposeInterfaceRef            (USBPB *                pb);
  543.  
  544. EXTERN_API_C( OSStatus )
  545. USBConfigureInterface            (USBPB *                pb);
  546.  
  547. EXTERN_API_C( OSStatus )
  548. USBFindNextPipe                    (USBPB *                pb);
  549.  
  550.  
  551. /* Dealing with descriptors. */
  552. /* Note most of this is temprorary */
  553. EXTERN_API_C( OSStatus )
  554. USBGetConfigurationDescriptor    (USBPB *                pb);
  555.  
  556. EXTERN_API_C( OSStatus )
  557. USBGetFullConfigurationDescriptor (USBPB *                pb);
  558.  
  559. EXTERN_API_C( OSStatus )
  560. USBFindNextEndpointDescriptorImmediate (USBPB *            pb);
  561.  
  562. EXTERN_API_C( OSStatus )
  563. USBFindNextInterfaceDescriptorImmediate (USBPB *        pb);
  564.  
  565. EXTERN_API_C( OSStatus )
  566. USBFindNextAssociatedDescriptor    (USBPB *                pb);
  567.  
  568.  
  569.  
  570. /* Utility functions */
  571. EXTERN_API_C( OSStatus )
  572. USBResetDevice                    (USBPB *                pb);
  573.  
  574. EXTERN_API_C( OSStatus )
  575. USBGetFrameNumberImmediate        (USBPB *                pb);
  576.  
  577. EXTERN_API_C( OSStatus )
  578. USBDelay                        (USBPB *                pb);
  579.  
  580. EXTERN_API_C( OSStatus )
  581. USBAllocMem                        (USBPB *                pb);
  582.  
  583. EXTERN_API_C( OSStatus )
  584. USBDeallocMem                    (USBPB *                pb);
  585.  
  586. /* Expert interface functions */
  587. EXTERN_API_C( OSStatus )
  588. USBExpertInstallInterfaceDriver    (USBDeviceRef             ref,
  589.                                  USBDeviceDescriptorPtr  desc,
  590.                                  USBInterfaceDescriptorPtr  interfacePtr,
  591.                                  USBReference             hubRef,
  592.                                  UInt32                 busPowerAvailable);
  593.  
  594. EXTERN_API_C( OSStatus )
  595. USBExpertRemoveInterfaceDriver    (USBDeviceRef             ref);
  596.  
  597. EXTERN_API_C( OSStatus )
  598. USBExpertInstallDeviceDriver    (USBDeviceRef             ref,
  599.                                  USBDeviceDescriptorPtr  desc,
  600.                                  USBReference             hubRef,
  601.                                  UInt32                 port,
  602.                                  UInt32                 busPowerAvailable);
  603.  
  604. EXTERN_API_C( OSStatus )
  605. USBExpertRemoveDeviceDriver        (USBDeviceRef             ref);
  606.  
  607. EXTERN_API_C( OSStatus )
  608. USBExpertStatus                    (USBDeviceRef             ref,
  609.                                  void *                    pointer,
  610.                                  UInt32                 value);
  611.  
  612. EXTERN_API_C( OSStatus )
  613. USBExpertFatalError                (USBDeviceRef             ref,
  614.                                  OSStatus                 status,
  615.                                  void *                    pointer,
  616.                                  UInt32                 value);
  617.  
  618. EXTERN_API_C( OSStatus )
  619. USBExpertNotify                    (void *                    note);
  620.  
  621. EXTERN_API_C( OSStatus )
  622. USBExpertSetDevicePowerStatus    (USBDeviceRef             ref,
  623.                                  UInt32                 reserved1,
  624.                                  UInt32                 reserved2,
  625.                                  UInt32                 powerStatus,
  626.                                  UInt32                 busPowerAvailable,
  627.                                  UInt32                 busPowerNeeded);
  628.  
  629.  
  630. enum {
  631.     kUSBDevicePower_PowerOK        = 0,
  632.     kUSBDevicePower_BusPowerInsufficient = 1,
  633.     kUSBDevicePower_BusPowerNotAllFeatures = 2,
  634.     kUSBDevicePower_SelfPowerInsufficient = 3,
  635.     kUSBDevicePower_SelfPowerNotAllFeatures = 4,
  636.     kUSBDevicePower_HubPortOk    = 5,
  637.     kUSBDevicePower_HubPortOverCurrent = 6,
  638.     kUSBDevicePower_BusPoweredHubOnLowPowerPort = 7,
  639.     kUSBDevicePower_BusPoweredHubToBusPoweredHub = 8,
  640.     kUSBDevicePower_Reserved3    = 9,
  641.     kUSBDevicePower_Reserved4    = 10
  642. };
  643.  
  644.  
  645. /* For hubs only */
  646. EXTERN_API_C( OSStatus )
  647. USBHubAddDevice                    (USBPB *                pb);
  648.  
  649. EXTERN_API_C( OSStatus )
  650. USBHubConfigurePipeZero            (USBPB *                pb);
  651.  
  652. EXTERN_API_C( OSStatus )
  653. USBHubSetAddress                (USBPB *                pb);
  654.  
  655. EXTERN_API_C( OSStatus )
  656. USBHubDeviceRemoved                (USBPB *                pb);
  657.  
  658.  
  659. EXTERN_API_C( UInt8 )
  660. USBMakeBMRequestType            (UInt8                     direction,
  661.                                  UInt8                     reqtype,
  662.                                  UInt8                     recipient);
  663.  
  664. /* This not implemented until someone shows me a test case */
  665. /*OSStatus USBControlRequest(USBPB *pb);*/
  666.  
  667. typedef UInt32                             USBLocationID;
  668.  
  669. enum {
  670.     kUSBLocationNibbleFormat    = 0                                /* Other values are reserved for future types (like when we have more than 16 ports per hub)*/
  671. };
  672.  
  673.  
  674.  
  675. enum {
  676.     kNoDeviceRef                = -1
  677. };
  678.  
  679. /* Expert Notification Types*/
  680. typedef UInt8                             USBNotificationType;
  681. typedef UInt8                             USBDriverMessage;
  682.  
  683. enum {
  684.     kNotifyAddDevice            = 0x00,
  685.     kNotifyRemoveDevice            = 0x01,
  686.     kNotifyAddInterface            = 0x02,
  687.     kNotifyRemoveInterface        = 0x03,
  688.     kNotifyGetDeviceDescriptor    = 0x04,
  689.     kNotifyGetInterfaceDescriptor = 0x05,
  690.     kNotifyGetNextDeviceByClass    = 0x06,
  691.     kNotifyGetDriverConnectionID = 0x07,
  692.     kNotifyInstallDeviceNotification = 0x08,
  693.     kNotifyRemoveDeviceNotification = 0x09,
  694.     kNotifyDeviceRefToBusRef    = 0x0A,
  695.     kNotifyDriverNotify            = 0x0C,
  696.     kNotifyParentNotify            = 0x0D,
  697.     kNotifyAnyEvent                = 0xFF,
  698.     kNotifyPowerState            = 0x17,
  699.     kNotifyStatus                = 0x18,
  700.     kNotifyFatalError            = 0x19
  701. };
  702.  
  703. /*
  704.    USB Manager wildcard constants for USBGetNextDeviceByClass
  705.    and USBInstallDeviceNotification.
  706. */
  707. typedef UInt16                             USBManagerWildcard;
  708.  
  709. enum {
  710.     kUSBAnyClass                = 0xFFFF,
  711.     kUSBAnySubClass                = 0xFFFF,
  712.     kUSBAnyProtocol                = 0xFFFF,
  713.     kUSBAnyVendor                = 0xFFFF,
  714.     kUSBAnyProduct                = 0xFFFF
  715. };
  716.  
  717.  
  718.  
  719.  
  720. struct ExpertNotificationData {
  721.     USBNotificationType             notification;
  722.     UInt8                             filler[1];                    /* unused due to 2-byte 68k alignment*/
  723.     USBDeviceRef *                    deviceRef;
  724.     UInt32                             busPowerAvailable;
  725.     void *                            data;
  726.     UInt32                             info1;
  727.     UInt32                             info2;
  728. };
  729. typedef struct ExpertNotificationData    ExpertNotificationData;
  730. typedef ExpertNotificationData *        ExpertNotificationDataPtr;
  731. /* Definition of function pointer passed in ExpertEntryProc*/
  732. typedef CALLBACK_API_C( OSStatus , ExpertNotificationProcPtr )(ExpertNotificationDataPtr pNotificationData);
  733. /* Definition of expert's callback installation function*/
  734. typedef CALLBACK_API_C( OSStatus , ExpertEntryProcPtr )(ExpertNotificationProcPtr pExpertNotify);
  735. /* Device Notification Callback Routine*/
  736. typedef CALLBACK_API_C( void , USBDeviceNotificationCallbackProcPtr )(void *pb);
  737. /* Device Notification Parameter Block*/
  738.  
  739. struct USBDeviceNotificationParameterBlock {
  740.     UInt16                             pbLength;
  741.     UInt16                             pbVersion;
  742.     USBNotificationType             usbDeviceNotification;
  743.     UInt8                             reserved1[1];                /* needed because of 2-byte 68k alignment*/
  744.     USBDeviceRef                     usbDeviceRef;
  745.     UInt16                             usbClass;
  746.     UInt16                             usbSubClass;
  747.     UInt16                             usbProtocol;
  748.     UInt16                             usbVendor;
  749.     UInt16                             usbProduct;
  750.     OSStatus                         result;
  751.     UInt32                             token;
  752.     USBDeviceNotificationCallbackProcPtr  callback;
  753.     UInt32                             refcon;
  754. };
  755. typedef struct USBDeviceNotificationParameterBlock USBDeviceNotificationParameterBlock;
  756. /* Forward declaration*/
  757. typedef USBDeviceNotificationParameterBlock * USBDeviceNotificationParameterBlockPtr;
  758. /* Definition of USBDriverNotificationCallback Routine*/
  759. typedef CALLBACK_API_C( void , USBDriverNotificationCallbackPtr )(OSStatus status, UInt32 refcon);
  760. /* Public Functions*/
  761. EXTERN_API_C( OSStatus )
  762. USBGetNextDeviceByClass            (USBDeviceRef *            deviceRef,
  763.                                  CFragConnectionID *    connID,
  764.                                  UInt16                 theClass,
  765.                                  UInt16                 theSubClass,
  766.                                  UInt16                 theProtocol);
  767.  
  768. EXTERN_API_C( OSStatus )
  769. USBGetDeviceDescriptor            (USBDeviceRef *            deviceRef,
  770.                                  USBDeviceDescriptor *    deviceDescriptor,
  771.                                  UInt32                 size);
  772.  
  773. EXTERN_API_C( OSStatus )
  774. USBGetInterfaceDescriptor        (USBInterfaceRef *        interfaceRef,
  775.                                  USBInterfaceDescriptor * interfaceDescriptor,
  776.                                  UInt32                 size);
  777.  
  778. EXTERN_API_C( OSStatus )
  779. USBGetDriverConnectionID        (USBDeviceRef *            deviceRef,
  780.                                  CFragConnectionID *    connID);
  781.  
  782. EXTERN_API_C( void )
  783. USBInstallDeviceNotification    (USBDeviceNotificationParameterBlock * pb);
  784.  
  785. EXTERN_API_C( OSStatus )
  786. USBRemoveDeviceNotification        (UInt32                 token);
  787.  
  788. EXTERN_API_C( OSStatus )
  789. USBDeviceRefToBusRef            (USBDeviceRef *            deviceRef,
  790.                                  USBBusRef *            busRef);
  791.  
  792. EXTERN_API_C( OSStatus )
  793. USBDriverNotify                    (USBReference             reference,
  794.                                  USBDriverMessage         mesg,
  795.                                  UInt32                 refcon,
  796.                                  USBDriverNotificationCallbackPtr  callback);
  797.  
  798. EXTERN_API_C( OSStatus )
  799. USBExpertNotifyParent            (USBReference             reference,
  800.                                  void *                    pointer);
  801.  
  802. typedef CALLBACK_API_C( void , HIDInterruptProcPtr )(UInt32 refcon, void *theData);
  803. /* HID Install Interrupt prototype*/
  804. typedef CALLBACK_API_C( OSStatus , USBHIDInstallInterruptProcPtr )(HIDInterruptProcPtr pInterruptProc, UInt32 refcon);
  805. /* HID Poll Device prototype*/
  806. typedef CALLBACK_API_C( OSStatus , USBHIDPollDeviceProcPtr )(void );
  807. /* HID Control Device prototype*/
  808. typedef CALLBACK_API_C( OSStatus , USBHIDControlDeviceProcPtr )(UInt32 theControlSelector, void *theControlData);
  809. /* HID Get Device Info prototype*/
  810. typedef CALLBACK_API_C( OSStatus , USBHIDGetDeviceInfoProcPtr )(UInt32 theInfoSelector, void *theInfo);
  811. /* HID Enter Polled Mode prototype*/
  812. typedef CALLBACK_API_C( OSStatus , USBHIDEnterPolledModeProcPtr )(void );
  813. /* HID Exit Polled Mode prototype*/
  814. typedef CALLBACK_API_C( OSStatus , USBHIDExitPolledModeProcPtr )(void );
  815.  
  816. struct USBHIDModuleDispatchTable {
  817.     UInt32                             hidDispatchVersion;
  818.     USBHIDInstallInterruptProcPtr     pUSBHIDInstallInterrupt;
  819.     USBHIDPollDeviceProcPtr         pUSBHIDPollDevice;
  820.     USBHIDControlDeviceProcPtr         pUSBHIDControlDevice;
  821.     USBHIDGetDeviceInfoProcPtr         pUSBHIDGetDeviceInfo;
  822.     USBHIDEnterPolledModeProcPtr     pUSBHIDEnterPolledMode;
  823.     USBHIDExitPolledModeProcPtr     pUSBHIDExitPolledMode;
  824. };
  825. typedef struct USBHIDModuleDispatchTable USBHIDModuleDispatchTable;
  826. typedef USBHIDModuleDispatchTable *        USBHIDModuleDispatchTablePtr;
  827. /*    Prototypes Tue, Mar 17, 1998 4:54:30 PM    */
  828. EXTERN_API_C( OSStatus )
  829. USBHIDInstallInterrupt            (HIDInterruptProcPtr     HIDInterruptFunction,
  830.                                  UInt32                 refcon);
  831.  
  832. EXTERN_API_C( OSStatus )
  833. USBHIDPollDevice                (void);
  834.  
  835. EXTERN_API_C( OSStatus )
  836. USBHIDControlDevice                (UInt32                 theControlSelector,
  837.                                  void *                    theControlData);
  838.  
  839. EXTERN_API_C( OSStatus )
  840. USBHIDGetDeviceInfo                (UInt32                 theInfoSelector,
  841.                                  void *                    theInfo);
  842.  
  843. EXTERN_API_C( OSStatus )
  844. USBHIDEnterPolledMode            (void);
  845.  
  846. EXTERN_API_C( OSStatus )
  847. USBHIDExitPolledMode            (void);
  848.  
  849. EXTERN_API_C( void )
  850. HIDNotification                    (UInt32                 devicetype,
  851.                                  UInt8                     NewHIDData[],
  852.                                  UInt8                     OldHIDData[]);
  853.  
  854.  
  855. enum {
  856.     kHIDRqGetReport                = 1,
  857.     kHIDRqGetIdle                = 2,
  858.     kHIDRqGetProtocol            = 3,
  859.     kHIDRqSetReport                = 9,
  860.     kHIDRqSetIdle                = 10,
  861.     kHIDRqSetProtocol            = 11
  862. };
  863.  
  864.  
  865. enum {
  866.     kHIDRtInputReport            = 1,
  867.     kHIDRtOutputReport            = 2,
  868.     kHIDRtFeatureReport            = 3
  869. };
  870.  
  871.  
  872. enum {
  873.     kHIDBootProtocolValue        = 0,
  874.     kHIDReportProtocolValue        = 1
  875. };
  876.  
  877.  
  878. enum {
  879.     kHIDKeyboardInterfaceProtocol = 1,
  880.     kHIDMouseInterfaceProtocol    = 2
  881. };
  882.  
  883.  
  884. enum {
  885.     kHIDSetLEDStateByBits        = 1,
  886.     kHIDSetLEDStateByBitMask    = 1,
  887.     kHIDSetLEDStateByIDNumber    = 2,
  888.     kHIDRemoveInterruptHandler    = 3,
  889.     kHIDEnableDemoMode            = 4,
  890.     kHIDDisableDemoMode            = 5
  891. };
  892.  
  893.  
  894. enum {
  895.     kHIDGetLEDStateByBits        = 1,                            /* not supported in 1.0 of keyboard module*/
  896.     kHIDGetLEDStateByBitMask    = 1,                            /* not supported in 1.0 of keyboard module*/
  897.     kHIDGetLEDStateByIDNumber    = 2,
  898.     kHIDGetDeviceCountryCode    = 3,                            /* not supported in 1.0 HID modules*/
  899.     kHIDGetDeviceUnitsPerInch    = 4,                            /* only supported in mouse HID module*/
  900.     kHIDGetInterruptHandler        = 5,
  901.     kHIDGetCurrentKeys            = 6,                            /* only supported in keyboard HID module*/
  902.     kHIDGetInterruptRefcon        = 7,
  903.     kHIDGetVendorID                = 8,
  904.     kHIDGetProductID            = 9
  905. };
  906.  
  907.  
  908.  
  909. enum {
  910.     kNumLockLED                    = 0,
  911.     kCapsLockLED                = 1,
  912.     kScrollLockLED                = 2,
  913.     kComposeLED                    = 3,
  914.     kKanaLED                    = 4
  915. };
  916.  
  917.  
  918. enum {
  919.     kNumLockLEDMask                = 1 << kNumLockLED,
  920.     kCapsLockLEDMask            = 1 << kCapsLockLED,
  921.     kScrollLockLEDMask            = 1 << kScrollLockLED,
  922.     kComposeLEDMask                = 1 << kComposeLED,
  923.     kKanaLEDMask                = 1 << kKanaLED
  924. };
  925.  
  926.  
  927. enum {
  928.     kUSBCapsLockKey                = 0x39,
  929.     kUSBNumLockKey                = 0x53,
  930.     kUSBScrollLockKey            = 0x47
  931. };
  932.  
  933.  
  934. struct USBMouseData {
  935.     UInt16                             buttons;
  936.     SInt16                             XDelta;
  937.     SInt16                             YDelta;
  938. };
  939. typedef struct USBMouseData                USBMouseData;
  940. typedef USBMouseData *                    USBMouseDataPtr;
  941.  
  942. struct USBKeyboardData {
  943.     UInt16                             keycount;
  944.     UInt16                             usbkeycode[32];
  945. };
  946. typedef struct USBKeyboardData            USBKeyboardData;
  947. typedef USBKeyboardData *                USBKeyboardDataPtr;
  948.  
  949. union USBHIDData {
  950.     USBKeyboardData                 kbd;
  951.     USBMouseData                     mouse;
  952. };
  953. typedef union USBHIDData                USBHIDData;
  954. typedef USBHIDData *                    USBHIDDataPtr;
  955. EXTERN_API_C( void )
  956. StartCompoundClassDriver        (USBDeviceRef             device,
  957.                                  UInt16                 classID,
  958.                                  UInt16                 subClass);
  959.  
  960.  
  961. enum {
  962.     kUSBCompositeClass            = 0,
  963.     kUSBAudioClass                = 1,
  964.     kUSBCommClass                = 2,
  965.     kUSBHIDClass                = 3,
  966.     kUSBDisplayClass            = 4,
  967.     kUSBPrintingClass            = 7,
  968.     kUSBMassStorageClass        = 8,
  969.     kUSBHubClass                = 9,
  970.     kUSBDataClass                = 10,
  971.     kUSBVendorSpecificClass        = 0xFF
  972. };
  973.  
  974.  
  975. enum {
  976.     kUSBCompositeSubClass        = 0,
  977.     kUSBHubSubClass                = 1
  978. };
  979.  
  980.  
  981. enum {
  982.     kUSBHIDInterfaceClass        = 0x03
  983. };
  984.  
  985.  
  986. enum {
  987.     kUSBNoInterfaceSubClass        = 0x00,
  988.     kUSBBootInterfaceSubClass    = 0x01
  989. };
  990.  
  991.  
  992. enum {
  993.     kUSBNoInterfaceProtocol        = 0x00,
  994.     kUSBKeyboardInterfaceProtocol = 0x01,
  995.     kUSBMouseInterfaceProtocol    = 0x02
  996. };
  997.  
  998.  
  999.  
  1000.  
  1001. enum {
  1002.     kServiceCategoryUSB            = FOUR_CHAR_CODE('usb ')        /* USB*/
  1003. };
  1004.  
  1005. /* SOMETHING NEEDS TO BE DONE WITH THIS - */
  1006.  
  1007. enum {
  1008.     kUSBTypeIsHub                = FOUR_CHAR_CODE('hubd'),        /* Hub*/
  1009.     kUSBTypeIsHID                = FOUR_CHAR_CODE('HIDd'),        /* Human Interface Device*/
  1010.     kUSBTypeIsDisplay            = FOUR_CHAR_CODE('disp'),        /* Display */
  1011.     kUSBTypeIsModem                = FOUR_CHAR_CODE('modm')        /* Modem*/
  1012. };
  1013.  
  1014.  
  1015. enum {
  1016.     kUSBDriverFileType            = FOUR_CHAR_CODE('ndrv'),
  1017.     kUSBDriverRsrcType            = FOUR_CHAR_CODE('usbd'),
  1018.     kUSBShimRsrcType            = FOUR_CHAR_CODE('usbs')
  1019. };
  1020.  
  1021.  
  1022. enum {
  1023.     kTheUSBDriverDescriptionSignature = FOUR_CHAR_CODE('usbd')
  1024. };
  1025.  
  1026.  
  1027. enum {
  1028.     kInitialUSBDriverDescriptor    = 0
  1029. };
  1030.  
  1031.  
  1032.  
  1033. typedef UInt32                             USBDriverDescVersion;
  1034. /*  Driver Loading Options*/
  1035. typedef UInt32                             USBDriverLoadingOptions;
  1036.  
  1037. enum {
  1038.     kUSBDoNotMatchGenericDevice    = 0x00000001,                    /* Driver's VendorID must match Device's VendorID*/
  1039.     kUSBDoNotMatchInterface        = 0x00000002,                    /* Do not load this driver as an interface driver.*/
  1040.     kUSBProtocolMustMatch        = 0x00000004,                    /* Do not load this driver if protocol field doesn't match.*/
  1041.     kUSBInterfaceMatchOnly        = 0x00000008                    /* Only load this driver as an interface driver.*/
  1042. };
  1043.  
  1044.  
  1045. enum {
  1046.     kClassDriverPluginVersion    = 0x00001100
  1047. };
  1048.  
  1049.  
  1050.  
  1051.  
  1052. struct USBDeviceInfo {
  1053.     UInt16                             usbVendorID;                /* USB Vendor ID*/
  1054.     UInt16                             usbProductID;                /* USB Product ID.*/
  1055.     UInt16                             usbDeviceReleaseNumber;        /* Release Number of Device*/
  1056.     UInt16                             usbDeviceProtocol;            /* Protocol Info.*/
  1057. };
  1058. typedef struct USBDeviceInfo            USBDeviceInfo;
  1059. typedef USBDeviceInfo *                    USBDeviceInfoPtr;
  1060.  
  1061. struct USBInterfaceInfo {
  1062.     UInt8                             usbConfigValue;                /* Configuration Value*/
  1063.     UInt8                             usbInterfaceNum;            /* Interface Number*/
  1064.     UInt8                             usbInterfaceClass;            /* Interface Class*/
  1065.     UInt8                             usbInterfaceSubClass;        /* Interface SubClass*/
  1066.     UInt8                             usbInterfaceProtocol;        /* Interface Protocol*/
  1067. };
  1068. typedef struct USBInterfaceInfo            USBInterfaceInfo;
  1069. typedef USBInterfaceInfo *                USBInterfaceInfoPtr;
  1070.  
  1071. struct USBDriverType {
  1072.     Str31                             nameInfoStr;                /* Driver's name when loading into the Name Registry.*/
  1073.     UInt8                             usbDriverClass;                /* USB Class this driver belongs to.*/
  1074.     UInt8                             usbDriverSubClass;            /* Module type*/
  1075.     NumVersion                         usbDriverVersion;            /* Class driver version number.*/
  1076. };
  1077. typedef struct USBDriverType            USBDriverType;
  1078. typedef USBDriverType *                    USBDriverTypePtr;
  1079.  
  1080. struct USBDriverDescription {
  1081.     OSType                             usbDriverDescSignature;        /* Signature field of this structure.*/
  1082.     USBDriverDescVersion             usbDriverDescVersion;        /* Version of this data structure.*/
  1083.     USBDeviceInfo                     usbDeviceInfo;                /* Product & Vendor Info*/
  1084.     USBInterfaceInfo                 usbInterfaceInfo;            /* Interface info*/
  1085.     USBDriverType                     usbDriverType;                /* Driver Info.*/
  1086.     USBDriverLoadingOptions         usbDriverLoadingOptions;    /* Options for class driver loading.*/
  1087. };
  1088. typedef struct USBDriverDescription        USBDriverDescription;
  1089. typedef USBDriverDescription *            USBDriverDescriptionPtr;
  1090. /*
  1091.    Dispatch Table
  1092.    Definition of class driver's HW Validation proc.
  1093. */
  1094. typedef CALLBACK_API_C( OSStatus , USBDValidateHWProcPtr )(USBDeviceRef device, USBDeviceDescriptorPtr pDesc);
  1095. /*
  1096.    Definition of class driver's device initialization proc.
  1097.    Called if the driver is being loaded for a device
  1098. */
  1099. typedef CALLBACK_API_C( OSStatus , USBDInitializeDeviceProcPtr )(USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable);
  1100. /* Definition of class driver's interface initialization proc.*/
  1101. typedef CALLBACK_API_C( OSStatus , USBDInitializeInterfaceProcPtr )(UInt32 interfaceNum, USBInterfaceDescriptorPtr pInterface, USBDeviceDescriptorPtr pDevice, USBInterfaceRef interfaceRef);
  1102. /* Definition of class driver's finalization proc.*/
  1103. typedef CALLBACK_API_C( OSStatus , USBDFinalizeProcPtr )(USBDeviceRef device, USBDeviceDescriptorPtr pDesc);
  1104.  
  1105. typedef UInt32                             USBDriverNotification;
  1106.  
  1107. enum {
  1108.     kNotifySystemSleepRequest    = 0x00000001,
  1109.     kNotifySystemSleepDemand    = 0x00000002,
  1110.     kNotifyHubEnumQuery            = 0x00000006,
  1111.     kNotifyChildMessage            = 0x00000007,
  1112.     kNotifyDriverBeingRemoved    = 0x0000000B
  1113. };
  1114.  
  1115. /*
  1116.    Definition of driver's notificatipn proc.      
  1117.    Added refcon for 1.1 version of dispatch table
  1118. */
  1119. typedef CALLBACK_API_C( OSStatus , USBDDriverNotifyProcPtr )(USBDriverNotification notification, void *pointer, UInt32 refcon);
  1120.  
  1121. struct USBClassDriverPluginDispatchTable {
  1122.     UInt32                             pluginVersion;
  1123.     USBDValidateHWProcPtr             validateHWProc;                /* Proc for driver to verify proper HW*/
  1124.     USBDInitializeDeviceProcPtr     initializeDeviceProc;        /* Proc that initializes the class driver.*/
  1125.     USBDInitializeInterfaceProcPtr     initializeInterfaceProc;    /* Proc that initializes a particular interface in the class driver.*/
  1126.     USBDFinalizeProcPtr             finalizeProc;                /* Proc that finalizes the class driver.*/
  1127.     USBDDriverNotifyProcPtr         notificationProc;            /* Proc to pass notifications to the driver.*/
  1128. };
  1129. typedef struct USBClassDriverPluginDispatchTable USBClassDriverPluginDispatchTable;
  1130. typedef USBClassDriverPluginDispatchTable * USBClassDriverPluginDispatchTablePtr;
  1131. /* Hub defines*/
  1132.  
  1133.  
  1134.  
  1135. enum {
  1136.     kUSBHubDescriptorType        = 0x29
  1137. };
  1138.  
  1139.  
  1140. enum {
  1141.                                                                 /* Hub features */
  1142.     kUSBHubLocalPowerChangeFeature = 0,
  1143.     kUSBHubOverCurrentChangeFeature = 1,                        /* port features */
  1144.     kUSBHubPortConnectionFeature = 0,
  1145.     kUSBHubPortEnablenFeature    = 1,
  1146.     kUSBHubPortSuspecdFeature    = 2,
  1147.     kUSBHubPortOverCurrentFeature = 3,
  1148.     kUSBHubPortResetFeature        = 4,
  1149.     kUSBHubPortPowerFeature        = 8,
  1150.     kUSBHubPortLowSpeedFeature    = 9,
  1151.     kUSBHubPortConnectionChangeFeature = 16,
  1152.     kUSBHubPortEnableChangeFeature = 17,
  1153.     kUSBHubPortSuspendChangeFeature = 18,
  1154.     kUSBHubPortOverCurrentChangeFeature = 19,
  1155.     kUSBHubPortResetChangeFeature = 20
  1156. };
  1157.  
  1158.  
  1159.  
  1160. enum {
  1161.     kHubPortConnection            = 1,
  1162.     kHubPortEnabled                = 2,
  1163.     kHubPortSuspend                = 4,
  1164.     kHubPortOverCurrent            = 8,
  1165.     kHubPortBeingReset            = 16,
  1166.     kHubPortPower                = 0x0100,
  1167.     kHubPortSpeed                = 0x0200
  1168. };
  1169.  
  1170.  
  1171. enum {
  1172.     kHubLocalPowerStatus        = 1,
  1173.     kHubOverCurrentIndicator    = 2,
  1174.     kHubLocalPowerStatusChange    = 1,
  1175.     kHubOverCurrentIndicatorChange = 2
  1176. };
  1177.  
  1178.  
  1179. enum {
  1180.     off                            = false,
  1181.     on                            = true
  1182. };
  1183.  
  1184.  
  1185.  
  1186. struct hubDescriptor {
  1187.                                                                 /* See usbDoc pg 250?? */
  1188.     UInt8                             dummy;                        /* to align charcteristics */
  1189.  
  1190.     UInt8                             length;
  1191.     UInt8                             hubType;
  1192.     UInt8                             numPorts;
  1193.  
  1194.     UInt16                             characteristics;
  1195.     UInt8                             powerOnToGood;                /* Port settling time, in 2ms */
  1196.     UInt8                             hubCurrent;
  1197.  
  1198.                                                                 /* These are received packed, will have to be unpacked */
  1199.     UInt8                             removablePortFlags[8];
  1200.     UInt8                             pwrCtlPortFlags[8];
  1201. };
  1202. typedef struct hubDescriptor            hubDescriptor;
  1203.  
  1204.  
  1205.  
  1206. #if PRAGMA_STRUCT_ALIGN
  1207.     #pragma options align=reset
  1208. #elif PRAGMA_STRUCT_PACKPUSH
  1209.     #pragma pack(pop)
  1210. #elif PRAGMA_STRUCT_PACK
  1211.     #pragma pack()
  1212. #endif
  1213.  
  1214. #ifdef PRAGMA_IMPORT_OFF
  1215. #pragma import off
  1216. #elif PRAGMA_IMPORT
  1217. #pragma import reset
  1218. #endif
  1219.  
  1220. #ifdef __cplusplus
  1221. }
  1222. #endif
  1223.  
  1224. #endif /* __USB__ */
  1225.  
  1226.